/**
 * @(#)RegisterWidget.java 2011
 *
 * Copyright 2011 classic-commerce
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 * @author: <a href="mailto:richard@ioniq.ca">Richard Mutezintare</a>
 *
 */

package ca.ioniq.client.widget.content;

import java.util.List;

import ca.ioniq.client.ClassicMessages;
import ca.ioniq.client.widget.ErrorMessageWidget;

import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.TextBox;

public class RegisterWidget extends FlowPanel {
    private static String ID = "account_body";

    private ErrorMessageWidget errors;

    private TextBox usernameTexBox;
    private TextBox emailTexBox;
    private TextBox passwordTextBox;
    private TextBox confirmPasswordTexBox;
    private TextBox streetNameTexBox;
    private TextBox streetNumberTexBox;

    private ListBox countryListBox;
    private ListBox provinceListBox;

    private TextBox postalCodeTexBox;

    private Button submitButton;
    private Button resetButton;

    private CheckBox female;
    private CheckBox male;

    public RegisterWidget(ErrorMessageWidget errors, ClassicMessages messages) {
        this.errors = errors;

        Label usernameLabel = new Label(messages.usernameLabel());
        Label passwordLabel = new Label(messages.passwordLabel());
        Label confirmPasswordLabel = new Label(messages.confirmPasswordLabel());
        Label emailLabel = new Label(messages.emailLabel());
        Label genderLabel = new Label(messages.genderLabel());
        Label streetNameLabel = new Label(messages.streetNameLabel());
        Label streetNumberLabel = new Label(messages.streetNumberLabel());
        Label countryLabel = new Label(messages.countryLabel());
        Label provinceLabel = new Label(messages.provinceState());
        Label cityLabel = new Label(messages.cityLabel());
        Label postalCodeLabel = new Label(messages.postalCodeLabel());

        countryListBox = new ListBox();
        countryListBox.addItem("");
        countryListBox.addItem("Canada");
        countryListBox.addItem("US");

        countryListBox.setVisibleItemCount(1); // make it a drop down menu

        provinceListBox = new ListBox();

        submitButton = new Button(messages.passwordLabel());
        resetButton = new Button(messages.passwordLabel());

        female = new CheckBox(messages.female());
        male = new CheckBox(messages.male());
    }

    public CheckBox getMale() { return male; }
    public CheckBox getFemale() { return female; }

    public Button getResetButton() { return resetButton; }
    public Button getSubmitButton() { return submitButton; }

    public TextBox getPostalCodeTexBox() {
        return postalCodeTexBox;
    }

    public void setCountryList(final List<String> countryList) {
        // contains two hard coded countries for now
    }

    public ListBox getCountryListBox() {
        return countryListBox;
    }

    public ListBox getProvinceListBox() {
        return provinceListBox;
    }

    // TODO sort list in in alphabetical order in the presenter
    public void setProvinceList(List<String> provinceList) {
        provinceListBox.clear();

        for(String name : provinceList) provinceListBox.addItem(name);
    }

    public TextBox getStreetNumberTexBox() {
        return streetNumberTexBox;
    }

    public TextBox getStreetNameTexBox() {
        return streetNameTexBox;
    }

    public TextBox getConfirmPasswordTexBox() {
        return confirmPasswordTexBox;
    }

    public TextBox getPasswordTextBox() {
        return passwordTextBox;
    }

    public TextBox getEmailTexBox() {
        return emailTexBox;
    }

    public TextBox getUsernameTexBox() {
        return usernameTexBox;
    }
}
